﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Windows.Data;
using System.Windows.Media;
using System.Globalization;

namespace DiagramDesigner.Utils
{
    public class Tools
    {
    }


    [ValueConversion(typeof(object), typeof(int))]
    public class NumberToPolarValueConverter : IValueConverter
    {
        public object Convert(
            object value, Type targetType,
            object parameter, CultureInfo culture)
        {
            double number = (double)System.Convert.ChangeType(value, typeof(double));

            if (number < 0.0)
                return -1;

            if (number == 0.0)
                return 0;

            return +1;
        }

        public object ConvertBack(
            object value, Type targetType,
            object parameter, CultureInfo culture)
        {
            throw new NotSupportedException("ConvertBack not supported");
        }
    }

    public class MaterialToImagePathConverter : IValueConverter
    {
        public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            switch (value.ToString())
            {
                case "Line":
                    return "Resources/Images/Line.png";
                case "LineSet":
                    return "Resources/Images/LineSet.png";
                case "Point":
                    return "Resources/Images/Point.png";
                case "PointSet":
                    return "Resources/Images/PointSet.png";
                case "Surface":
                    return "Resources/Images/Surface.png";
                case "SurfaceSet":
                    return "Resources/Images/SurfaceSet.png";
                default:
                    return "Resources/Images/blank.png";
            }
        }

        public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public class MeasureAttribute
    {       

        public enum TypeImageMeasureAttribute
        {
            Line,
            LineSet,
            Point,
            PointSet,
            Surface,
            SurfaceSet,
            TimeLine,
            TimeLineSet,
            TimePoint,
            TimePointSet,
            TimeSurface,
            TimeSurfaceSet,
            None
        }

        public MeasureAttribute()
        {
        }

        /*
        public MeasureAttribute(int ID, string Name, int PackType, TypeImageMeasureAttribute BaseImage)
        {
            this.ElementID = ID;
            this.ElementName = Name;
            this.FunctionAgregation = string.Empty;

            switch(PackType.ToString())
            {                
                case "1":
                    this.ElementType = "VT";
                    break;
                case "0":
                    this.ElementType = "";
                    break;
            }
            switch (BaseImage.ToString())
            {
                case "Line":
                    this.RutaImagen = "Resources/Images/Line.png";
                    break;
                case "LineSet":
                    this.RutaImagen = "Resources/Images/LineSet.png";
                    break;
                case "Point":
                    this.RutaImagen = "Resources/Images/Point.png";
                    break;
                case "PointSet":
                    this.RutaImagen = "Resources/Images/PointSet.png";
                    break;
                case "Surface":
                    this.RutaImagen = "Resources/Images/Surface.png";
                    break;
                case "SurfaceSet":
                    this.RutaImagen = "Resources/Images/SurfaceSet.png";
                    break;
                case "TimeLine":
                    this.RutaImagen = "Resources/Images/TimeLine.png";
                    break;
                case "TimeLineSet":
                    this.RutaImagen = "Resources/Images/TimeLineSet.png";
                    break;
                case "TimePoint":
                    this.RutaImagen = "Resources/Images/TimePoint.png";
                    break;
                case "TimePointSet":
                    this.RutaImagen = "Resources/Images/TimePointSet.png";
                    break;
                case "TimeSurface":
                    this.RutaImagen = "Resources/Images/TimeSurface.png";
                    break;
                case "TimeSurfaceSet":
                    this.RutaImagen = "Resources/Images/TimeSurfaceSet.png";
                    break;
                default:
                    this.RutaImagen = "Resources/Images/blank.png";
                    break;
            }            
            //this.Image = BaseImage;
            //this.RutaImagen = Ruta;
        }
        */
        public MeasureAttribute(int ID, string Name, int PackType, TypeImageMeasureAttribute BaseImage)
        {
            this.ElementID = ID;
            this.ElementName = Name;
            this.FunctionAgregation = string.Empty;

            switch (PackType.ToString())
            {                
                case "1":
                    this.ElementType = "VT";
                    break;
                case "0":
                    this.ElementType = "";
                    break;
            }
            switch (BaseImage.ToString())
            {
                case "Line":
                    this.RutaImagen = "Resources/Images/Line.png";
                    break;
                case "LineSet":
                    this.RutaImagen = "Resources/Images/LineSet.png";
                    break;
                case "Point":
                    this.RutaImagen = "Resources/Images/Point.png";
                    break;
                case "PointSet":
                    this.RutaImagen = "Resources/Images/PointSet.png";
                    break;
                case "Surface":
                    this.RutaImagen = "Resources/Images/Surface.png";
                    break;
                case "SurfaceSet":
                    this.RutaImagen = "Resources/Images/SurfaceSet.png";
                    break;
                case "TimeLine":
                    this.RutaImagen = "Resources/Images/TimeLine.png";
                    break;
                case "TimeLineSet":
                    this.RutaImagen = "Resources/Images/TimeLineSet.png";
                    break;
                case "TimePoint":
                    this.RutaImagen = "Resources/Images/TimePoint.png";
                    break;
                case "TimePointSet":
                    this.RutaImagen = "Resources/Images/TimePointSet.png";
                    break;
                case "TimeSurface":
                    this.RutaImagen = "Resources/Images/TimeSurface.png";
                    break;
                case "TimeSurfaceSet":
                    this.RutaImagen = "Resources/Images/TimeSurfaceSet.png";
                    break;
                default:
                    this.RutaImagen = "Resources/Images/blank.png";
                    break;
            }           
        }

        private int _ElementID;
        public int ElementID
        {
            get { return _ElementID; }
            set { _ElementID = value; }
        }

        private string _ElementName;
        public string ElementName
        {
            get { return _ElementName; }
            set { _ElementName = value; }
        }

        private string _ElementType;
        public string ElementType
        {
            get { return _ElementType; }
            set { _ElementType = value; }
        }

        private TypeImageMeasureAttribute _Imagen;
        public TypeImageMeasureAttribute Image
        {
            get { return _Imagen; }
            set { _Imagen = value; }
        }

        private string _RutaImagen;
        public string RutaImagen
        {
            get { return _RutaImagen; }
            set { _RutaImagen = value; }
        }


        private string _FunctionAgregation;
        public string FunctionAgregation
        {
            get { return _FunctionAgregation; }
            set { _FunctionAgregation = value; }
        }
       

        public static List<MeasureAttribute> StockCheck()
        {
            List<MeasureAttribute> CurrentItems = new List<MeasureAttribute>();
            {
                //CurrentItems.Add(new MeasureAttribute(1, "Name", TypeTemporalSpatial.LifeSpan, TypeImageMeasureAttribute.Surface));
                //CurrentItems.Add(new MeasureAttribute(-2, "Ape. Paterno", TypeTemporalSpatial.ValidTime, TypeImageMeasureAttribute.Surface));
                //CurrentItems.Add(new MeasureAttribute(-3, "Ape. Materno", TypeTemporalSpatial.None, TypeImageMeasureAttribute.Line));
                //CurrentItems.Add(new MeasureAttribute("A4", "Direccion", TypeTemporalSpatial.LifeSpan, TypeImageMeasureAttribute.LineSet));
                //CurrentItems.Add(new MeasureAttribute("A5", "Telefono", TypeTemporalSpatial.LifeSpan, TypeImageMeasureAttribute.Surface));
                //CurrentItems.Add(new MeasureAttribute("A6", "Celular", TypeTemporalSpatial.ValidTime, TypeImageMeasureAttribute.Point));
                //CurrentItems.Add(new MeasureAttribute("A7", "DNI", TypeTemporalSpatial.ValidTime, TypeImageMeasureAttribute.SurfaceSet));
                //CurrentItems.Add(new MeasureAttribute("A8", "Edad", TypeTemporalSpatial.None, TypeImageMeasureAttribute.None));
                //CurrentItems.Add(new MeasureAttribute("A9", "Sueldo", TypeTemporalSpatial.LifeSpan, TypeImageMeasureAttribute.Line));
                //CurrentItems.Add(new MeasureAttribute("A10", "Categoria", TypeTemporalSpatial.None, TypeImageMeasureAttribute.None));
            }

            return CurrentItems;
        }

    }
}
